﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using BUS;
using DAO;

public partial class Demo_AB : System.Web.UI.Page
{
    BUS_WRAREA _bus_wrarea = new BUS_WRAREA();
    BUS_WRREGION _bus_wrregion = new BUS_WRREGION();
    BUS_WRCITY _bus_wrcity = new BUS_WRCITY();

    protected void Page_Load(object sender, EventArgs e)
    {
        iSelect.ServerClick += new EventHandler(iSelect_ServerClick);

        if (!IsPostBack)
        {
            BulletedList1.DataValueField = "ID";
            BulletedList1.DataTextField = "AreaName";
            BulletedList1.DataSource = _bus_wrarea._GetList(p=>p.IDLang==1);
            BulletedList1.DataBind();
        }
    }

    void iSelect_ServerClick(object sender, EventArgs e)
    {
    }
    protected void BulletedList1_Click(object sender, BulletedListEventArgs e)
    {
        try
        {
            int ID = Convert.ToInt32(BulletedList1.Items[e.Index].Value);

            IList<WRREGION> iListWRREGION = new List<WRREGION>();
            iListWRREGION = _bus_wrregion._GetList(p => p.IDArea == ID);

            BulletedList2.DataValueField = "ID";
            BulletedList2.DataTextField = "RegionName";
            BulletedList2.DataSource = iListWRREGION;
            BulletedList2.DataBind();



            BulletedList3.DataSource = null;
            BulletedList3.DataBind();

            BulletedList3.Items.Clear();
        }
        catch (Exception ex)
        {
            
            throw;
        }
    }
    protected void BulletedList2_Click(object sender, BulletedListEventArgs e)
    {
        try
        {
            int ID = Convert.ToInt32(BulletedList2.Items[e.Index].Value);

            IList<WRCITY> iListWRWRCITY = new List<WRCITY>();
            iListWRWRCITY = _bus_wrcity._GetList(p => p.IDRegion == ID);

            BulletedList3.DataValueField = "ID";
            BulletedList3.DataTextField = "CityName";
            BulletedList3.DataSource = iListWRWRCITY;
            BulletedList3.DataBind();

            //if (iListWRREGION.Count() > 0)
            //{
            //    BulletedList2.DataValueField = "ID";
            //    BulletedList2.DataTextField = "RegionName";
            //    BulletedList2.DataSource = iListWRREGION;
            //    BulletedList2.DataBind();

            //}
        }
        catch (Exception ex)
        {

            throw;
        }
    }
}